//
//  DATFlingy.m
//  MapEdit
//
//  Created by Steven Canfield on 28/06/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "DATFlingy.h"

#define NUM_FLINGY 209

@implementation DATFlingy
- (id)initWithData:(NSData *)data {
	self = [super init];
	if( self ) {
		flingy = malloc( sizeof( dat_flingy_t ) * NUM_FLINGY );
		
		int flingyIndex;
		int dataIndex = 0;
		for( flingyIndex = 0; flingyIndex < NUM_FLINGY; flingyIndex++ ) {
			/* Read Unit Info */
			u_int16_t buff16;
			[data getBytes:&buff16 range:NSMakeRange( dataIndex, sizeof( u_int16_t ))];
			buff16 = NSSwapLittleShortToHost( buff16 );
			dataIndex += sizeof( u_int16_t );
			flingy[ flingyIndex ].sprite_index = buff16;
		}
	}
	return self;
}

- (dat_flingy_t *)flingyAtIndex:(int)index {
//	NSLog(@"%@ => %i", NSStringFromSelector(_cmd), index );
	return &( flingy[ index ] );
}
@end
